package com.cy.pj.sys.controller;

import com.cy.pj.sys.pojo.SysLog;
import com.cy.pj.sys.pojo.common.util.PageUtil;
import com.cy.pj.sys.service.SysLogService;
import com.cy.pj.sys.web.pojo.TesResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/log/")
public class SysController {
    @Autowired
    private SysLogService sysLogService;

    @GetMapping("{id}")
    public TesResult doFindById(@PathVariable Long id){
        return new TesResult(sysLogService.findById(id));
    }

    @DeleteMapping("{ids}")
    public TesResult doDeleteById(@PathVariable Long... ids){
        sysLogService.deleteById(ids);
        return new TesResult("delete ok");
    }

    @GetMapping
    public TesResult doFindLogs(SysLog sysLog){
        return new TesResult(PageUtil.startPage().
                doSelectPageInfo(()->
                        sysLogService.findLogs(sysLog)
                ));
    }

    /*@PostMapping
    public TesResult doSaveLog(@RequestBody SysLog sysLog){
        sysLogService.saveLog(sysLog);
        return new TesResult("save ok");
    }*/

}
